package cn.ichensw.otherworldlystationbackend.controller;

import cn.ichensw.otherworldlystationbackend.common.BaseResponse;
import cn.ichensw.otherworldlystationbackend.common.DoubanPageRequest;
import cn.ichensw.otherworldlystationbackend.common.PageRequest;
import cn.ichensw.otherworldlystationbackend.common.ResultUtils;
import cn.ichensw.otherworldlystationbackend.model.dto.douban.DoubanSearchMovieRequest;
import cn.ichensw.otherworldlystationbackend.model.vo.douban.DoubanMovieUsBoxVO;
import cn.ichensw.otherworldlystationbackend.model.vo.douban.DoubanSearchMovieVO;
import cn.ichensw.otherworldlystationbackend.service.DoubanService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 豆瓣接口Controller
 */
@Api(value = "豆瓣查询接口", tags = "DoubanController")
@RestController
@RequestMapping("/douban")
public class DoubanController {

    @Resource
    private DoubanService doubanService;

    /**
     * 根据标签/关键字搜索电影条目
     *
     * @param request 请求参数
     * @return 电影列表
     */
    @ApiOperation("根据标签/关键字搜索电影条目")
    @PostMapping("/v2/movie/search")
    public BaseResponse<Page<DoubanSearchMovieVO>> searchMovie(@RequestBody DoubanSearchMovieRequest request, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(doubanService.searchMovie(request, httpServletRequest));
    }

    /**
     * 根据 id 查询电影详情
     *
     * @param id 电影id
     * @return 电影列表
     */
    @ApiOperation("根据id查询电影详情")
    @GetMapping("/v2/movie/subject/{id}")
    public BaseResponse<DoubanSearchMovieVO> movieSubjectDetail(@PathVariable("id") Long id, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(doubanService.movieSubjectDetail(id, httpServletRequest));
    }

    /**
     * 查询电影 TOP250
     *
     * @param request 分页参数
     * @return 电影列表
     */
    @ApiOperation("电影TOP250")
    @PostMapping("/v2/movie/top250")
    public BaseResponse<Page<DoubanSearchMovieVO>> movieTop250(@RequestBody DoubanPageRequest request, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(doubanService.movieTop250(request, httpServletRequest));
    }

    /**
     * 查询电影 北美票房榜
     *
     * @return 电影列表
     */
    @ApiOperation("北美票房榜")
    @PostMapping("/v2/movie/us_box")
    public BaseResponse<DoubanMovieUsBoxVO> movieUsBox(@RequestBody DoubanPageRequest request, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(doubanService.movieUsBox(request, httpServletRequest));
    }

    /**
     * 查询电影口碑榜-接口有问题
     *
     * @return 电影列表
     */
    @ApiOperation("电影口碑榜-接口有问题")
    @PostMapping("/v2/movie/weekly")
    public BaseResponse<Page<DoubanSearchMovieVO>> movieWeekly(@RequestBody DoubanPageRequest request, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(doubanService.movieWeekly(request, httpServletRequest));
    }

    /**
     * 查询电影 新片榜-接口有问题
     *
     * @return 电影列表
     */
    @ApiOperation("电影新片榜-接口有问题")
    @PostMapping("/v2/movie/new_movies")
    public BaseResponse<Page<DoubanSearchMovieVO>> movieNew(@RequestBody DoubanPageRequest request, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(doubanService.movieNew(request, httpServletRequest));
    }

    /**
     * 查询电影 正在上映
     *
     * @return 电影列表
     */
    @ApiOperation("正在上映电影")
    @PostMapping("/v2/movie/in_theaters")
    public BaseResponse<Page<DoubanSearchMovieVO>> movieInTheaters(@RequestBody DoubanPageRequest request, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(doubanService.movieInTheaters(request, httpServletRequest));
    }

    /**
     * 查询电影 即将上映
     *
     * @return 电影列表
     */
    @ApiOperation("即将上映电影")
    @PostMapping("/v2/movie/coming_soon")
    public BaseResponse<Page<DoubanSearchMovieVO>> movieComingSoon(@RequestBody DoubanPageRequest request, HttpServletRequest httpServletRequest) {
        return ResultUtils.success(doubanService.movieComingSoon(request, httpServletRequest));
    }


}
